require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module XyyTemplate2018
  class Application < Rails::Application
    config.assets.paths << Rails.root.join('vendor', 'assets', 'fonts')
    config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
    config.generators do |g|
      g.test_framework :rspec,
                       fixtures: true,
                       view_specs: false,
                       helper_specs: false,
                       routing_specs: false,
                       controller_specs: false,
                       request_specs: false
      g.fixture_replacement :factory_girl, dir: 'spec/factories'
    end

    config.generators.assets = false
    config.generators.helper = false

    config.time_zone = 'Beijing'
    config.i18n.available_locales = %i[en zh-CN]
    config.i18n.default_locale = :'zh-CN'
    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]

    config.lograge.enabled = true
    # 在log里显示params参数
    # config.lograge.custom_options = lambda do |event|
    #   exceptions = %w(controller action format id)
    #   {
    #       params: event.payload[:params].except(*exceptions)
    #   }
    # end
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1
    # 设置belongs_to默认不是必填项
    config.active_record.belongs_to_required_by_default = false

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
    #
    config.autoload_paths += Dir[Rails.root.join('app', 'uploaders', '*.rb').to_s]
  end
end
